{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 三、多元函数的极限\n",
    "\n",
    "先讨论二元函数 $z = f(x, y)$ 当 $(x, y) \\to (x_0, y_0)$，即 *P*（$x, y \\to P_0(x_0, y_0)$）时的极限。这里 $P \\to P_0$ 表示点 *P* 以任何方式趋于点 *P_0*，也就是 *P* 与点 *P_0* 间的距离趋于零，即\n",
    "\n",
    "$$\n",
    "|PP_{0}| = \\sqrt{(x - x_{0})^{2} + (y - y_{0})^{2}} \\to 0.\n",
    "$$\n",
    "\n",
    "与一元函数的极限概念类似，如果在 $P(x, y) \\to P_0(x_0, y_0)$ 的过程中，对应的函数值 $f(x, y)$ 无限接近于一个确定的常数 *A*，那么就说 *A* 是函数 $f(x, y)$ 当 $(x, y) \\to (x_0, y_0)$ 时的极限。下面用“$\\varepsilon$-$\\delta$”语言描述这个极限概念。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 定义 2\n",
    "设二元函数 $f(P) = f(x, y)$ 的定义域为 $D$，点 $P_0 (x_0, y_0)$ 是 $D$ 的聚点。如果存在常数 $A$，对于任意给定的正数 $\\varepsilon$，总存在正数 $\\delta$，使得当点 $P (x, y) \\in D \\cap \\hat{U}(P_0, \\delta)$ 时，都有\n",
    "$$\n",
    "|f(P) - A| = |f(x, y) - A| < \\varepsilon\n",
    "$$\n",
    "成立，那么就称常数 $A$ 为函数 $f(x, y)$ 当 $(x, y) \\to (x_0, y_0)$ 时的极限，记作\n",
    "$$\n",
    "\\lim_{(x, y) \\to (x_0, y_0)} f(x, y) = A \\quad \\text{或} \\quad f(x, y) \\to A \\quad ((x, y) \\to (x_0, y_0)),\n",
    "$$\n",
    "也记作\n",
    "$$\n",
    "\\lim_{P \\to P_0} f(P) = A \\quad \\text{或} \\quad f(P) \\to A \\quad (P \\to P_0).\n",
    "$$\n",
    "为了区别于一元函数的极限，我们把二元函数的极限叫做二重极限。\n",
    "\n",
    "## 例4\n",
    "设 $f(x, y) = (x^2 + y^2) \\sin \\frac{1}{x^2 + y^2}$，求证：\n",
    "$$\n",
    "\\lim_{(x, y) \\to (0, 0)} f(x, y) = 0.\n",
    "$$\n",
    "证 这里函数 $f(x, y)$ 的定义域为 $D = \\mathbb{R}^2 \\setminus \\{(0, 0)\\}$，点 $O(0, 0)$ 为 $D$ 的聚点。因为\n",
    "$$\n",
    "|f(x, y) - 0| = |(x^2 + y^2) \\sin \\frac{1}{x^2 + y^2} - 0| \\leq x^2 + y^2,\n",
    "$$\n",
    "可见，$\\forall \\varepsilon > 0$，取 $\\delta = \\sqrt{\\varepsilon}$，则当\n",
    "$$\n",
    "0 < \\sqrt{(x - 0)^2 + (y - 0)^2} < \\delta,\n",
    "$$\n",
    "即 $P(x, y) \\in D \\cap U(0, \\delta)$ 时，总有\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 极限理论\n",
    "\n",
    "必须注意，所谓二重极限存在，是指 $P(x, y)$ 以任何方式趋于 $P_0(x_0, y_0)$ 时，$f(x, y)$ 都无限接近于 $A$。因此，如果 $P(x, y)$ 以某一特殊方式，例如沿着一条定直线或定曲线趋于 $P_0(x_0, y_0)$ 时，即使 $f(x, y)$ 无限接近于某一确定值，我们还不能由此断定函数的极限存在。但是反过来，如果当 $P(x, y)$ 以不同的方式趋于 $P_0(x_0, y_0)$ 时，$f(x, y)$ 趋于不同的值，那么就可以断定这函数的极限不存在。下面用例子来说明这种情形。\n",
    "\n",
    "考察函数\n",
    "$$\n",
    "f(x, y) = \\begin{cases} \n",
    "\\frac{xy}{x^2 + y^2}, & x^2 + y^2 \n",
    "eq 0, \\\\\n",
    "0, & x^2 + y^2 = 0.\n",
    "\\end{cases}\n",
    "$$\n",
    "显然，当点 $P(x, y)$ 沿 $x$ 轴趋于点 $(0, 0)$ 时，\n",
    "$$\n",
    "\\lim_{(x, y) \\to (0, 0)} f(x, y) = \\lim_{x \\to 0} f(x, 0) = \\lim_{x \\to 0} 0 = 0;\n",
    "$$\n",
    "又当点 $P(x, y)$ 沿 $y$ 轴趋于点 $(0, 0)$ 时，\n",
    "$$\n",
    "\\lim_{(x, y) \\to (0, 0)} f(x, y) = \\lim_{y \\to 0} f(0, y) = \\lim_{y \\to 0} 0 = 0.\n",
    "$$\n",
    "虽然点 $P(x, y)$ 以上述两种特殊方式（沿 $x$ 轴或沿 $y$ 轴）趋于原点时函数的极限存在并且相等，但是 $\\lim_{(x, y) \\to (0, 0)} f(x, y)$ 并不存在。这是因为当点 $P(x, y)$ 沿着直线 $y = kx$ 趋于点 $(0, 0)$ 时，有\n",
    "$$\n",
    "\\lim_{(x, y) \\to (0, 0)} \\frac{2xy}{x^2 + y^2} = \\lim_{x \\to 0} \\frac{kx^2}{x^2 + k^2x^2} = \\frac{k}{1 + k^2}.\n",
    "$$\n",
    "显然它是随着 $k$ 的值的不同而改变的。\n",
    "\n",
    "以上关于二元函数的极限概念，可相应地推广到 $n$ 元函数 $u = f(P)$，即 $u = f(x_1, x_2, \\cdots, x_n)$ 上去。\n",
    "\n",
    "关于多元函数的极限运算，有与一元函数类似的运算法则。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**例5** 求 $\\lim _{(x, y)\\rightarrow (0, 2)}\\frac{\\sin (xy)}{x}$.\n",
    "\n",
    "**解** 这里函数 $\\frac{\\sin (\\chi \\pi )}{x}$ 的定义域为 $D=\\{ (x, y)|x\n",
    "eq 0, y\\in \\mathbb{R}\\}, P_{0}(0, 2)$ 为 *D* 的聚点.\n",
    "\n",
    "由积的极限运算法则，得\n",
    "\n",
    "$$\n",
    "\\lim _{(x, y)\\rightarrow (0, 2)}\\frac{\\sin (xy)}{x}=\\lim _{(x, y)\\rightarrow (0, 2)}[\\frac{\\sin (xy)}{xy} \\cdot y]=\\lim _{xy\\rightarrow 0}\\frac{\\sin (xy)}{xy} \\cdot \\lim _{y\\rightarrow 2}=1\\cdot 2=2.\n",
    "$$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义变量和函数\n",
    "x = sp.symbols('x')\n",
    "f = sp.sin(x)\n",
    "\n",
    "# 计算定积分\n",
    "integral = sp.integrate(f, (x, 0, sp.pi))\n",
    "\n",
    "print(integral)  # 输出结果"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
